package com.atguigu.boot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.jms.Topic;
import java.util.Date;

@Service
public class Topic_Produce {
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;
    @Autowired
    private Topic topic;
    @Scheduled(fixedDelay = 1000)
    public void produceTopic(){
        jmsMessagingTemplate.convertAndSend(topic,new Date().toString());
        System.out.println("投放一条消息");
    }
}
